import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TestBoard extends TestCase {
    private static final Class thisClass = TestBoard.class;

    public static void main(String[] args) {
        if (args.length >= 1 && args[0].equals("text")) {
            junit.textui.TestRunner.run(thisClass);
        } else {
            junit.swingui.TestRunner.run(thisClass);
        }
    }

    public static Test suite() {
        return new TestSuite(thisClass);
    }

    public void testInitBoard() {
        Board b = new Board();
        assertEquals(0x00000FFF, b.black);
        assertEquals(0xFFF00000, b.white);
        assertEquals(0, b.kings);
    }

    public void testParseBoardInit() {
        Board board = Board.parseCwb(
            "  b   b   b   b",
            "b   b   b   b  ",
            "  b   b   b   b",
            "  -   -   -   -",
            "-   -   -   -  ",
            "  w   w   w   w",
            "w   w   w   w  ",
            "  w   w   w   w",
            "b");
        assertEquals(0x00000FFF, board.black);
        assertEquals(0xFFF00000, board.white);
        assertEquals(0, board.kings);
        assertTrue(board.blackToMove);
    }

    public void testParseWdp() {
        Board board = Board.parseWdp(
            "bbbb bbbb bbbb .... .... wwww wwww wwww b");
        assertEquals(0x00000FFF, board.black);
        assertEquals(0xFFF00000, board.white);
        assertEquals(0, board.kings);
        assertTrue(board.blackToMove);
    }
}
